<template>
  <el-dialog
    title="审核"
    :visible.sync="show"
    width="30%"
    :before-close="enaminecancel"
    :close-on-click-modal="false"
  >
    <el-form
      ref="form"
      :model="examineForm"
      label-width="80px"
      :rules="examinerules"
    >
      <el-form-item label="审核状态" prop="status">
        <el-select v-model="examineForm.status" placeholder="审核状态">
          <el-option
            v-for="dict in this.getDictDatas('student_check_status')"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="审核备注" prop="content">
        <el-input type="textarea" v-model="examineForm.content"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="enaminesubmit()">确定</el-button>
        <el-button @click="enaminecancel()">取消</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
import request from "@/utils/request";
import { adminUrl } from "@/utils/baseUrl.js"
export default {
  name: "examine",
  props: {
    // 是否显示弹出层
    show: {
      type: Boolean,
      default: false,
    },
    // 显示弹出层标题
    title: {
      type: String,
      default: "",
    },
    //获取选中事件
    handleSelectArr: {
      type: Array,
      default: [],
    },
  },
  data() {
    return {
      examineForm: {
      },
      // 表单校验
      examinerules: {
        status: [{ required: true, message: "审核状态不能为空", trigger: "blur" }],
        content: [{ required: true, message: "审核备注不能为空", trigger: "blur" }],
      },
    };
  },
  methods: {
    enaminecancel() {
      this.$emit("update:show", false);
      this.enaminereset();
    },
    enaminereset() {
      this.examineForm = {
        status: "",
        content: "",
      };
    },
    //审核提交
    async enaminesubmit() {
      this.$refs["form"].validate(async (valid) => {
        if (!valid) {
          return;
        }
        let res = await request({
          url: adminUrl + "/collegebase/student-roll/check",
          method: "put",
          data: {
            checkRemark: this.examineForm.content,
            checkStatus: this.examineForm.status,
            id: this.handleSelectArr[0]["id"],
          },
        });
        this.$emit("update:show", false);
        this.enaminereset();
        if (res.data) {
          this.$modal.msgSuccess("操作成功");
          this.$parent.getList();
        }
      });


    },
  },
};
</script>

<style>
</style>
